<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function* gen(){
            console.log('第一个状态');
            yield 111;
            console.log('第二个状态');
            yield 222;
            console.log('第三个状态');
            yield 333;
        }

        let iterator = gen();
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());

        function* gen(){
            console.log('第一个状态');
            yield 111;
            console.log('第二个状态');
            yield 222;
            console.log('第三个状态');
            yield 333;
        }
    </script>
</body>
</html>